---------------------------------------------------------------
File name   :  vv_ahblite_end_test.e
Title       :  End of test
Project     :  vv_ahblite UVC
Developers  :  stefan,filip
Created     :  29.07.2011.
Description :  This file handles 'end of test'.

Notes       :  End-of-test handling is managed by the objection
    :  mechanism. Each proactive MAIN sequence raises an
    :  objection to TEST_DONE at the start of the sequence
    :  and drops the objection at the end of the sequence.
    :  A drain time (default: 10 cycles) is used to ensure
    :  that the test has really finished.
---------------------------------------------------------------
Copyright  (c)2011
---------------------------------------------------------------

<'

package vv_ahblite;

extend MAIN vv_ahblite_master_sequence {

    -- **********************************************************************
    -- IVB-NOTE : OPTIONAL : Implement end of test behavior : 06 End of test
    -- ----------------------------------------------------------------------
    -- In the  example that follows, an objection is raised at the beginning 
    -- of the main sequence and dropped after waiting the drain time.
    -- Use this section to implement your UVC end of test behavior.
    -- To do so edit the following example:
  
    -- Raise an objection to TEST_DONE whenever a MAIN sequence is started.
    pre_body() @sys.any is first {
        message(LOW, "MAIN sequence started");
        if prevent_test_done {
            driver.raise_objection(TEST_DONE);
        };
    };
         
    -- After the MAIN sequence ends, and the number of clock cycles defined
    -- by the drain time has passed, drop the objection to TEST_DONE. 
    post_body() @sys.any is also {
    	idle(0x00000008,BYTE);
        message(LOW, "MAIN sequence finished");
        if prevent_test_done {
           wait [drain_time] * cycle @driver.clock;
           driver.drop_objection(TEST_DONE);
        };
    };
     
    -- **********************************************************************
}; 

extend vv_ahblite_master {  --extend master agent

    -- This field is set if reset has been asserted during a test. It is used
    -- to ensure that the objection to TEST_DONE that is raised at the start
    -- of such a reset is dropped when reset is de-asserted.
    !reset_during_test : bool;

    run() is also {
        reset_during_test = FALSE;
};

    -- When reset is asserted, raise an objection to TEST_DONE so that the
    -- test continues, even though all sequence drivers have quit. The
    -- 'reset_during_test' flag is also set so that we know that, when reset
    -- is de-asserted, the objection needs to be dropped.

    reset_start() is first {
        reset_during_test = TRUE;
        raise_objection(TEST_DONE);
};

    reset_end() is first {
        if reset_during_test {
            reset_during_test = FALSE;
            drop_objection(TEST_DONE);
};
};

};

'>
